package com.lsh.respsitory;

import com.lsh.entity.Fastdfsfile;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

/**
 * @author ：LiuShihao
 * @date ：Created in 2020/9/2 10:04 上午
 * @desc ：
 */
public interface FastdfsRespsitory extends JpaRepository<Fastdfsfile,Integer>, JpaSpecificationExecutor<Fastdfsfile> {

    @Query(value = "select `name` from `fastdfsfile` where `url` = ?",nativeQuery = true)
    String findNameByUrl(String url);
    @Modifying
    @Query(value = "INSERT INTO `fastdfsfile`( `url`, `name`) VALUES (:#{#fastdfsfile.url}, :#{#fastdfsfile.name})",nativeQuery = true)
    void addFile(Fastdfsfile fastdfsfile);


}
